package misc.chars;

import org.flixel.FlxObject;
import org.flixel.FlxG;
import org.flixel.FlxState;
import org.flixel.FlxSound;
import org.flixel.tweens.misc.VarTween;
import org.flixel.tweens.FlxTween;
import org.flixel.util.FlxPoint;

/**
 * ...
 * @author ... Federico Donnet - Marcelo Guardia
 */
class JujuToki extends PlayableCharacter
{

	public function new(x: Float = 0.0, y:Float = 0.0, width:Int = 16, height:Int = 16, color:Int=0xffff0000) 
	{
		super(x, y);
		this.joypad = new Joystick();
		this.loadGraphic("assets/Resources/Textures/Sheets/Toki-Juju/toki_juju.png", true, true, 64, 64);
		
		//---* Animaciones
		//---*Stand:
		this.addAnimation("Stand", [0], 10, false);		
		//---*Shoot:
		this.addAnimation("Shoot", [47,48], 20, false);		
		//---*Run:
		this.addAnimation("Run", [1,2,3,4,5], 20, true);		
		//---*Jump:
		this.addAnimation("Jump", [13,14], 20, false);
		
		this.gravity				=	750.0;
		this.vx						=	250.0;		
		this.drag.x 				=	this.vx * 4.0; 		
		this.acceleration.y			=	this.gravity;
		this.acceleration.x			=	0;
		this.maxVelocity.x 			=	this.vx;
		this.maxVelocity.y 			=	this.gravity/2;		
		this.state					=	CharConst.STAND;
		this.play(GetStateNameAnimation());		
		//---*Le referenciamos el state:
		this.playState				=	cast( FlxG.state, PlayState);	
		this.name					=	"JujuToki";
		
		
		this.scale.x				=	1.2;
		this.scale.y				=	1.2;
		
		this.width					=	20 ;
		this.height					=	40 ;	
		this.centerOffsets(true);	
		//this.offset.x				=	6 ;
		this.offset.y				=	28;	
		
		this.playDustEmitt	=	true;
		this.health			=	2;
		
		this.alphaTween				= new VarTween(onTweenEnded, FlxTween.PINGPONG);
		this.alphaTween.tween(this, "alpha", 0, 0.05);
		this.alphaTween.active	=	false;
		this.addTween(this.alphaTween);
		
		this.ResetPosition = new FlxPoint(x, y);
		
	}
	
	override public function update():Void
	{
		super.update();
	}
	
	//---*Devuelve en String el nombre de la animacion del estado actual de Player:
	override public function GetStateNameAnimation():String
	{
		var name:String="";
		switch(this.state)
		{
			case	CharConst.STAND:	name 	=	"Stand"; 
			case	CharConst.RUN:		name 	=	"Run";
			case	CharConst.JUMP:		name	=	"Jump";
			case	CharConst.SHOOT: 	name	=	"Shoot";
			
			
		}
		return name;		 
	}
	
	override	public function GenerateShoot():Void 
	{	
		//despues cambiar por el hacha de wonderboy
		this.Shoot(this.x+15*dx,this.y+7.0,600.0);
	}
}